// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------

import request from '@/utils/request'


/**
 * 新增
 * @param
 */
export function addRole(pram) {
  const data = {
    exposureContent: pram.exposureContent,
    exposureTitle: pram.exposureTitle,
    type: pram.type,
    sort: pram.sort,
    id: pram.id
  }
  // data.rules = pram.rules.join(',')
  return request({
    url: '/add',
    method: 'post',
    data: data
  })
}

/**
 * 删除
 * @param
 */
export function deleteRole(pram) {
  const data = {
    id: pram.id
  }
  return request({
    url: '/delete',
    method: 'GET',
    params: data
  })
}

/**
 * 详情
 * @param
 */
export function getInfo(pram) {
  return request({
    url: `/getRoleById?id=${pram}`,
    method: 'GET',
  })
}

/**
 * 分页列表
 * @param
 */
export function getAllList(pram) {
  const data = {
    //createTime: pram.createTime,
    //updateTime: pram.updateTime,
    //level: pram.level,
    page: pram.page,
    limit: pram.limit,
    roleName: pram.roleName,
    //rules: pram.rules,
    keyWord: pram.title,
    type:pram.type,
    exposureTitle:pram.exposureTitle
  }
  return request({
    url: '/allBack',
    method: 'get',
    params: data
  })
}

/**
 * 修改
 * @param
 */
export function updateRole(pram) {
  const data = {
    exposureContent: pram.exposureContent,
    exposureTitle: pram.exposureTitle,
    type: pram.type,
    sort: pram.sort,
    id: pram.id
  }
  return request({
    url: '/update',
    method: 'post',
    data: data
  })
}
/**
 * 图片上传
 * @param data
 */
export function fileImageApi(data) {
  let url = '/uploadBack'
  return request({
    url: url,
    method: 'POST',
    data
  })
}

/**
 * 图片列表
 * @param params
 */
export function fileListApi(params,modelName) {
  let url = '/getAttachmentList'
  if (modelName === 'person') url = '/att/getAttachmentList'
  return request({
    url: url,
    method: 'get',
    params
  })
}

/**
 * 图片列表 删除图片
 * @param id
 */
export function fileDeleteApi(id,modelName) {
  let url = `/delAttachment?ids=${id}`
  if (modelName === 'person') url = `/att/delAttachment?ids=${id}`
  return request({
    url: url,
    method: 'get'
  })
}

/**
 * 图片列表 移動分類
 * @param data
 */
export function attachmentMoveApi(data,modelName) {
  let url = '/updateAttachment'
  if (modelName === 'person') url = '/att/updateAttachment'
  return request({
    url: url,
    method: 'post',
    data
  })
}

/**
 * 新增投诉
 * @param
 */
export function addComplaint(pram) {
  const data = {
    reflectorName: pram.reflectorName,
    reflectorMobile: pram.reflectorMobile,
    type: pram.type,
    isContract: pram.isContract,
    id: pram.id,
    salaryName: pram.salaryName,
    salaryMobile: pram.salaryMobile,
    actualLocation: pram.actualLocation,
    address: pram.address,
    unitName: pram.unitName,
    salaryCount: pram.salaryCount,
    salaryAmount: pram.salaryAmount,
    salaryTime: pram.salaryTime,
    information: pram.information,
    situation: pram.situation,
    pic: pram.swiperImage,
    projectName: pram.projectName,
    constructionName: pram.constructionName,
    subpackageName: pram.subpackageName,
    idCardFront: pram.idCardFront,
    idCardBack: pram.idCardBack,
  }
  // data.rules = pram.rules.join(',')
  return request({
    url: '/addComplaint',
    method: 'post',
    data: data
  })
}
